/**
 * 
 */
package com.topu.db.excel;

import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

/**
 * @author popofish
 * 
 */
public class DBExcelWriter implements IDBExcelWriter {

	private IDBWorkbook workbook;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.topu.db.excel.IDBExcelWriter#getWorkbook()
	 */
	@Override
	public IDBWorkbook getWorkbook() {
		return this.workbook;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.topu.db.excel.IDBExcelWriter#setWorkbook(com.topu.db.excel.
	 * IDBWorkbook)
	 */
	@Override
	public void setWorkbook(IDBWorkbook workbook) {
		this.workbook = workbook;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.topu.db.excel.IDBExcelWriter#write(java.lang.String)
	 */
	@Override
	public void write(String outputFile) {
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(outputFile);
			HSSFWorkbook workbook = new HSSFWorkbook();
			this.workbook.setWorkbook(workbook);
			workbook.write(fos);
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			try {
				fos.close();
			} catch (Exception ex) {
			}
		}

	}

}
